namespace IAM.Interface.Model
{
    using IAM.Interface.Common;
    using IAM.Interface.Model.Interface;
    using System;
    using System.Text;

    public class CheckedItem : AbstractConvertObject, IConvertXml
    {
        private string _acitemid = "";
        private string _attr1 = "";
        private string _attr2 = "";
        private string _attr3 = "";
        private string _attr4 = "";
        private string _attr5 = "";
        private string _attr6 = "";
        private string _attr7 = "";
        private string _attr8 = "";
        private bool _value = false;

        public override object ConvertToObject()
        {
            this.ACItemID = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["ACItemID"].InnerText);
            if (this.CurrentXmlNode.Attributes["Value"].InnerText.ToLower() == "check")
            {
                this.Value = true;
            }
            else
            {
                this.Value = false;
            }
            try
            {
                this.Attr1 = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["Attr1"].InnerText);
                this.Attr2 = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["Attr2"].InnerText);
                this.Attr3 = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["Attr3"].InnerText);
                this.Attr4 = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["Attr4"].InnerText);
                this.Attr5 = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["Attr5"].InnerText);
                this.Attr6 = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["Attr6"].InnerText);
                this.Attr7 = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["Attr7"].InnerText);
                this.Attr8 = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["Attr8"].InnerText);
            }
            catch
            {
            }
            return this;
        }

        public override bool Equals(object obj)
        {
            CheckedItem ci = null;
            try
            {
                ci = (CheckedItem) obj;
            }
            catch
            {
                return false;
            }
            bool result = true;
            if (this.ACItemID != ci.ACItemID)
            {
                result = false;
            }
            else
            {
                if (this.Value != ci.Value)
                {
                    return false;
                }
                if (this.Attr1 != ci.Attr1)
                {
                    return false;
                }
                if (this.Attr2 != ci.Attr2)
                {
                    return false;
                }
                if (this.Attr3 != ci.Attr3)
                {
                    return false;
                }
                if (this.Attr4 != ci.Attr4)
                {
                    return false;
                }
                if (this.Attr5 != ci.Attr5)
                {
                    return false;
                }
                if (this.Attr6 != ci.Attr6)
                {
                    return false;
                }
                if (this.Attr7 != ci.Attr7)
                {
                    result = false;
                }
                else if (this.Attr8 != ci.Attr8)
                {
                    result = false;
                }
            }
            return result;
        }

        public override int GetHashCode()
        {
            return (this._acitemid.GetHashCode() * this._value.GetHashCode());
        }

        public string ACItemID
        {
            get
            {
                return this._acitemid;
            }
            set
            {
                this._acitemid = value;
            }
        }

        public string Attr1
        {
            get
            {
                return this._attr1;
            }
            set
            {
                this._attr1 = value;
            }
        }

        public string Attr2
        {
            get
            {
                return this._attr2;
            }
            set
            {
                this._attr2 = value;
            }
        }

        public string Attr3
        {
            get
            {
                return this._attr3;
            }
            set
            {
                this._attr3 = value;
            }
        }

        public string Attr4
        {
            get
            {
                return this._attr4;
            }
            set
            {
                this._attr4 = value;
            }
        }

        public string Attr5
        {
            get
            {
                return this._attr5;
            }
            set
            {
                this._attr5 = value;
            }
        }

        public string Attr6
        {
            get
            {
                return this._attr6;
            }
            set
            {
                this._attr6 = value;
            }
        }

        public string Attr7
        {
            get
            {
                return this._attr7;
            }
            set
            {
                this._attr7 = value;
            }
        }

        public string Attr8
        {
            get
            {
                return this._attr8;
            }
            set
            {
                this._attr8 = value;
            }
        }

        public bool Value
        {
            get
            {
                return this._value;
            }
            set
            {
                this._value = value;
            }
        }

        public string XML
        {
            get
            {
                return (this.XMLBoday + this.XMLFinis);
            }
        }

        public string XMLBoday
        {
            get
            {
                StringBuilder _xml = new StringBuilder();
                _xml.Append("<CheckedItem");
                _xml.Append(" ACItemID=\"" + EnDeCoding.Encode(this.ACItemID) + "\"");
                if (this.Value)
                {
                    _xml.Append(" Value=\"check\"");
                }
                else
                {
                    _xml.Append(" Value=\"uncheck\"");
                }
                try
                {
                    _xml.Append(" Attr1=\"" + EnDeCoding.Encode(this.Attr1) + "\"");
                    _xml.Append(" Attr2=\"" + EnDeCoding.Encode(this.Attr2) + "\"");
                    _xml.Append(" Attr3=\"" + EnDeCoding.Encode(this.Attr3) + "\"");
                    _xml.Append(" Attr4=\"" + EnDeCoding.Encode(this.Attr4) + "\"");
                    _xml.Append(" Attr5=\"" + EnDeCoding.Encode(this.Attr5) + "\"");
                    _xml.Append(" Attr6=\"" + EnDeCoding.Encode(this.Attr6) + "\"");
                    _xml.Append(" Attr7=\"" + EnDeCoding.Encode(this.Attr7) + "\"");
                    _xml.Append(" Attr8=\"" + EnDeCoding.Encode(this.Attr8) + "\"");
                }
                catch
                {
                }
                _xml.Append(" />");
                return _xml.ToString();
            }
        }

        public string XMLFinis
        {
            get
            {
                return "";
            }
        }
    }
}
